﻿@{
    ViewBag.Title = "list";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>管理员管理</h5>
                    </div>
                    <div class="ibox-content">
                        <form role="form" class="form-inline" id="form1" name="form1">
                            <div class="form-group">
                                <label for="exampleInputEmail2" class="sr-only">关键字</label>
                                <input type="text" placeholder="请输入关键字" id="keyword" name="keyword" class="form-control">
                            </div>
                            <button class="btn btn-primary" type="button" onclick="add()">添加</button>
                            <button class="btn btn-white" type="button" id="btnsearch">查询</button>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                        <p>&nbsp;</p>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function () {

            $("#btnsearch").click(function () {
                $("#table_list_1").jqGrid('setGridParam', {
                    postData: $('#form1').serializeObject(),
                    page: 1
                }).trigger("reloadGrid"); //重新载入
            });

            $.jgrid.defaults.styleUI = 'Bootstrap';
            $("#table_list_1").jqGrid({
                url: '/AdminInfo/List',

                datatype: "json",
                mtype: 'POST',
                height: 'auto',
                autowidth: true,
                shrinkToFit: true,
                multiselect: true,
                multiboxonly: true,
                postData:$('#form1').serializeObject(),
                cellEdit: true,
                rowNum: 10,
                rowList: [10, 20, 30],
                colNames: ['', '账号', '姓名', '电话', '状态', '操作'],
                colModel: [
                    {
                        name: 'ID',
                        index: 'ID',
                        sortable: false,
                        width: '0%',
                        hidden: true
                    },
                    {
                        name: 'account',
                        index: 'account',
                        width: 180,
                    },
                    {
                        name: 'Name',
                        index: 'Name',
                        width: 180,
                    },
                    {
                        name: 'Phone',
                        index: 'Phone',
                        width: 600
                    },
                    {
                        label: '状态', name: 'status', index: 'status', width: 100, align: 'center',
                        formatter: function (cellvalue, options, rowObject) {
                            var ID =rowObject['ID'];
                            var m_check_status = "";
                            var m_CheckStatusName = "CheckStatus" +ID;
                            var m_check_value = "0";
                            if (cellvalue == 0)
                            {
                                m_check_status = "禁用";
                                m_check_value = "1";
                            }
                            if (cellvalue == 1)
                            {
                                m_check_status = "启用";
                                m_check_value = "0";
                            }
                            var actionlink = "&apos;/AdminInfo/Check&apos;";
                            return "<a href='#' id=" + m_CheckStatusName + " onclick='JavaScript:CheckStatus("+actionlink+","+ ID + "," + m_check_value + ")'>" + m_check_status + "</a>";
                        },

                    },
                     {
                         label: '修改', name: 'ID', index: 'ID', width: 100, align: 'center',
                         formatter: function (cellvalue, options, rowObject) {
                             var actionlink1 = "&apos;/AdminInfo/Delete&apos;";

                             return "<a data-toggle='modal' href='Edit?id=" + cellvalue + "' data-target='#mmXgmodal'>修改</a> | <a href='#' onclick='javascript:Delete(" + cellvalue + "," + actionlink1 + ")'>删除</a> ";
                         },
                     },
                ],
                jsonReader: {
                    root: "List",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false,
                },
                pager: "#pager_list_1",
                viewrecords: true,
                hidegrid: false
            });
            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
            });
            $('#mmXgmodal').on('hidden.bs.modal', function () {
                $(this).removeData('bs.modal');
            });
        });
 
        function add()
        {
            $("#mmXgmodal").modal({
                remote: "Add"
            });
        }

    </script>
    <div class="modal fade" id="mmXgmodal" tabindex="-1" role="dialog" aria-labelledby="modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content  animated bounceInRight">
            </div>
        </div>
    </div>

